import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        int max = -1;
        for(int i = 1; i <= s; i++) {
            if(xunZhao(i,s)) {
                max = i;
            }
        }
        System.out.println(max);
    }
    public static boolean xunZhao(int n,int s) {
        int h = 0;
        for(int i = 1; i <= n/2; i++) {
            if(n % i == 0) {
                h = i + n/i;
            }
        }
        return h == s;
    }
}
